import React, { useState } from 'react';

import { Select, SelectProps } from 'antd';

export default function(
  initValue: string,
): {
  value;
  setValue: (e: any) => void;
  DOM: ({ ...otherProps }: SelectProps<any>) => JSX.Element;
} {
  const [value, setValue] = useState<string>(initValue);
  const DOM = ({ ...otherProps }: SelectProps<any>): JSX.Element => (
    <Select
      {...otherProps}
      defaultValue={value}
      style={{ width: 120 }}
      onChange={e => setValue(e)}
    />
  );
  return {
    value,
    setValue,
    DOM,
  };
}
